/* components */
import FeedbackDialog from '@src/modules/task/view/components/TaskFeedback/FeedbackDialog.vue'
import ProposeApproveDialog from '@src/modules/task/view/components/ProposeApproveDialog.vue'
import sendSmsDlalog from './components/sendSmsDlalog.vue';
/* enum */
import ComponentNameEnum from '@model/enum/ComponentNameEnum'
/* model */
/* render */
import TaskReviewListRender from '@src/modules/task/taskTypes/review/TaskReviewListRender.tsx'
/* scss */
import '@src/modules/task/taskTypes/review/TaskReviewList.scss'
/* vue */
import { Component } from 'vue-property-decorator'
import { CreateElement } from 'vue'

import GuideContent from '@src/component/guide/contentCom/ProductSuperqrcodeSet.vue';

import { storageGet, storageSet } from '@src/util/storage'
import * as _  from 'lodash';


@Component({ 
  name: ComponentNameEnum.TaskReviewList,
  components: {
    [FeedbackDialog.name]: FeedbackDialog,
    [ProposeApproveDialog.name]: ProposeApproveDialog,
    [sendSmsDlalog.name]: sendSmsDlalog,
  }
})
export default class TaskReviewList extends TaskReviewListRender {
  
  async mounted() {
    // 恢复常用
    this.recoverCommonUse() 
    if(!storageGet(this.satisfactionTips)) {
      storageSet(this.satisfactionTips, '1')
      this.visibleGuide = true
    }
    // 读取按钮缓存
    this.refreshTask()
    // 获取初始化数据
    await this.fetchInitData()
    // 获取回访工单列表
    this.findFastPageData().then(()=>{
      this.search();
    });
    // 初始化工单字段列表
    this.initializeTaskTypeAllFields()
    // 获取全部工单类型数据
    this.fetchTaskTypesMap()
    // [tab_spec]标准化刷新方式
    window.__exports__refresh = async () => {
      setTimeout(() => {
        this.search()
      }, 1000)
      this.closeSmsDialog()
    }
    let that_ = this;
    // 监听切换后需要重新计算列表高度 后续可以用activated生命周期替换
    window.addEventListener('message', (event:any)=> {
      const {action, data} = event.data;
      if (action == 'shb.frame.activatedPage'){
        that_.$nextTick(()=> {
          that_.knowTableContainerHeight();
        })
      }
    });
    this.$nextTick(()=> {
      this.knowTableContainerHeight()
      window.onresize = _.debounce(()=>{
        that_.knowTableContainerHeight()
      }, 500)
    })
  }
  
  render(h: CreateElement) {
    // 属性列表
    const attrs = this.getAttributes()
    
    return (
      <div {...attrs}>
        { this.renderHeaderContainer() }
        { this.renderReviewPermissionContainer() }
        { this.renderOperationContainer() }
        { this.renderContentContainer() }
        { this.renderComponentsContainer() }
        { this.renderReviewGuide() }
      </div>
    )
    
  }
  
}

